package com.kfm.wiki.job;

import cn.hutool.core.util.IdUtil;
import com.kfm.wiki.service.EbookSnapshotService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class EbookSnapshotJob {

    @Autowired
    private EbookSnapshotService ebookSnapshotService;

    @Scheduled(cron = "0/30 * * * * ? ")
    public void testJob(){
        MDC.put("LOG_ID", String.valueOf(IdUtil.getSnowflakeNextId()));
        log.info("生成电子书快照开始");
        long start = System.currentTimeMillis();
        ebookSnapshotService.generateSnapshot();
        log.info("生成电子书快照完成，耗时：" + (System.currentTimeMillis() - start));
    }
}
